package com.zlx.guguanjia.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zlx.guguanjia.entity.Qualification;
import com.zlx.guguanjia.entity.QualificationConfiguration;
import com.zlx.guguanjia.entity.SysUser;
import com.zlx.guguanjia.mapper.QualificationMapper;
import com.zlx.guguanjia.mapper.SysUserMapper;
import com.zlx.guguanjia.service.QualificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Transactional
@Service
public class QualificationServiceImpl extends BaseServiceImpl<Qualification,Long> implements QualificationService {

    @Autowired
    private QualificationMapper mapper;


    @Autowired
    private SysUserMapper sysUserMapper;

    @Value("${staticPath}")
    String path;

    /***
     * @Author 周罗校
     * @Description 页面查询
     * @Param [start, pageSize, configuration]
     * @return com.github.pagehelper.PageInfo<com.zlx.guguanjia.entity.Qualification>
     * @Date 2020.10.26 15:46:48
     **/
    @Override
    public PageInfo<Qualification> selectPage(int start, int pageSize, QualificationConfiguration configuration) {
        PageHelper.startPage(start,pageSize);
        List<Qualification> qualifications = mapper.selectPage(configuration);
        return new PageInfo<Qualification>(qualifications);
    }
    
    
    /***
     * @Author 周罗校
     * @Description 根据id进行查询
     * @Param [id]
     * @return com.zlx.guguanjia.entity.Qualification
     * @Date 2020.10.26 15:47:07
     **/
    @Override
    public Qualification selectOne(Long id) {
        Qualification qualification = mapper.selectByPrimaryKey(id);
        SysUser sysUser = sysUserMapper.selectByPrimaryKey(qualification.getUploadUserId());
        qualification.setAddress(path+sysUser.getOfficeId()+"/"+qualification.getAddress());
        return qualification;
    }
}
